﻿// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.DependencyInjection;
using WorkflowCore.Console.Workflow;
using WorkflowCore.Interface;

// 获取服务容器
var serviceProvider = ConfigureServices();

// 获取工作流宿主
var host = serviceProvider.GetService<IWorkflowHost>();

// 注册工作流
host.RegisterWorkflow<HelloWordWorkflowCore>();

// 启动宿主
host.Start();

// 启动工作流
host.StartWorkflow("HelloWorld", 1, null);

Console.ReadLine();
host.Stop();


static IServiceProvider ConfigureServices()
{
    IServiceCollection services = new ServiceCollection();
    services.AddLogging();
    services.AddWorkflow();

    var serviceProvider = services.BuildServiceProvider();
    return serviceProvider;
}
